package com.niit.class_3.dao.impl;

import com.niit.class_3.dao.IUserDAO;
import com.niit.class_3.domain.Users;
import com.niit.class_3.util.DBHelper;

import java.sql.ResultSet;

public class UserDAOImpl implements IUserDAO {
    public Users queryUserByUserName(String userName) {
        String sql ="select * from tb_users where user_name = ?";
        ResultSet rs = DBHelper.executeQuery(sql, userName);
        Users user = null ;
        try {
            if(rs.next()){
                user = new Users(rs.getInt(1), rs.getString(2), rs.getString(3));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return user;
    }
}
